import random


def is_same(n):
    s = str(n)
    for i in range(len(s)):
        for j in range(i + 1, len(s)):
            if s[i] == s[j]:
                return 1
    return 0


generate = 11
x = 0
y = 0 
scan = -1
while is_same(generate) != 0:
    generate = random.randint(1021, 9999)
generate = str(generate)
while scan != generate:
    x = 0
    y = 0
    scan = input('请输入一个数:')
    for i in range(len(scan)):
        for j in range(len(generate)):
            if scan[i] == generate[j]:
                if i == j:
                    x += 1
                else:
                    y += 1
    print(f'{x}A{y}B')
print('猜对了')